import Layout from '@/layout'

const modulesFiles = require.context('.', false, /^((?!index).)*\.js$/)
console.log(modulesFiles.keys())
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  // set './app.js' => 'app'
  let moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
  const names = moduleName.split('/')
  moduleName = names[names.length - 1]
  const value = modulesFiles(modulePath)
  modules.children.push(value.default)
  return modules
}, {
  path: '/part',
  component: Layout,
  name: 'part',
  meta: {
    title: '部件',
    type: 'demo',
    icon: ''
  },
  children: []
})

export default modules
